package com.ruoyi.project.pandian.pandian.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.project.out.outStock.domain.OutStockoutVo;
import com.ruoyi.project.pandian.pandian.service.PDService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/pandian")
public class PDController {
    @Autowired
    private PDService pdService;

    private String prefix="pandian";

    @GetMapping("/add")
    public String add(){
        return prefix+"/addPdOut";
    }

    @GetMapping("/selectTray")
    public String selectTray(){
        return prefix+"/selectTrayCode";
    }

    @GetMapping("/pandian")
    public String pandian(){
        return prefix+"/pandian";
    }

    @GetMapping("/pdOutJob")
    public String pdOutJob(){
        return prefix+"/pdOutJob";
    }

    @GetMapping("/pdInJob")
    public String pdInJob(){
        return prefix+"/pdInJob";
    }
    @GetMapping("/pdByStock")
    public String pdByStock(){
        return prefix+"/pdByStock";
    }

    @RequestMapping("addSave")
    @ResponseBody
    public AjaxResult addSave(@RequestBody OutStockoutVo outStockoutVo){
        String stockoutId=pdService.addSavePDstock(outStockoutVo);
                return AjaxResult.success("保存成功！",stockoutId);
    }

    @RequestMapping("/autoAllocation")
    @ResponseBody
    public Map<String, Object> autoAllocation(@RequestParam("stockoutIds[]")String[] stockoutIds,@RequestParam("outType") String outType,@RequestParam("exitId") String exitId){
       return pdService.autoAllocation(stockoutIds,outType,exitId);
    }
    /**
    * 指定货位盘点
    */
    @RequestMapping("/assignCargoPd")
    @ResponseBody
    public AjaxResult assignCargoPd(String trayCode,String exitId){
       String msg= pdService.assignCargoPd(trayCode,exitId);
        return AjaxResult.success(msg);
    }


}
